package com.lysj.merchant.management.domain;


import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lysj.admin.utils.spring.foundation.base.BaseEntity;
import com.lysj.admin.utils.validation.annotation.NotBlank;
import com.lysj.admin.utils.validation.annotation.Pattern;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @author zk
 * @description 用户表
 * @create 2018-07-25 14:55
 **/
@Data
@Entity
@EqualsAndHashCode(callSuper = true)
@Table(name = "lysj_merchant_user")
public class User extends BaseEntity {
    @NotBlank(message = "用户名不能为空")
    @Pattern(pattern = "[a-zA-Z0-9_]{5,17}", message = "用户名应为英文、数字、下划线组成的5-17位字符")
//    @Unique(message = "用户名已存在")
    private String username;//用户名，登录账号，必填

//    @NotBlank(message = "密码不能为空")
//    @Pattern(pattern = "[a-zA-Z0-9_]{6,15}", message = "密码应为英文、数字、下划线组成的6-15位字符")
    @JsonIgnore
    private String password;//密码 必填

    private String phone; // 手机号码

    @Transient
    private List<Permission> permissions;//用户拥有的权限

    @Transient
    private List<Role> roles;//用户拥有的角色

    private Integer userType; // 用户类型，1：商户；2：店长；3：员工

    private String merchantId; // 商户id

    private String storeId; // 门店id，为空代表该员工为商户

}
